#include<bits/stdc++.h>
using namespace std;
const int NN=1004;
vector<int>t;
int n,a[NN],b[NN];
set<vector<int> >st;
void dfs(int x,int y)
{
	if(x==n&&y==n)
	{
		st.insert(t);
		return;
	}
	if(x<n)
	{
		t.push_back(b[y]);
		dfs(x+1,y);
		t.pop_back();
	}
	if(y<n)
	{
		t.push_back(a[x]);
		dfs(x,y+1);
		t.pop_back();
	}
}
int main()
{
	freopen("zha.in","r",stdin);
	freopen("zha.out","w",stdout);
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	for(int i=1;i<=n;i++)
		scanf("%d",&b[i]);
	dfs(1,1);
	printf("%d",st.size());
	return 0;
}
